import { createRouter, createWebHistory } from "vue-router";
//下面是导入需要路由导航的页面组件
// import Home from "../views/Home.vue";
import Profile from "../views/Profile.vue";

const router = createRouter({
  history: createWebHistory(),
  routes: [
    // {
    //   path: "/",
    //   name: "Home",
    //   component: Home,
    // },
    {
      path: "/",
      name: "Profile",
      component: Profile,
    },
    // {
    //   path: "/profile",
    //   name: "Profile",
    //   component: () => import("../views/Profile.vue"), //懒加载
    // },
    {
      path: "/login",
      name: "Login",
      component: () => import("../views/login/LoginView.vue"), //懒加载
    },
    {
      path: "/register",
      name: "Register",
      component: () => import("../views/register/RegisterView.vue"), //懒加载
    },
    {
      path: "/test",
      name: "Test",
      component: () => import("../views/Test.vue"), //懒加载
    },
    {
      path: "/mall",
      name: "Mall",
      component: () => import("../views/Mall.vue"), //懒加载
    },
    {
      path: "/about",
      name: "About",
      component: () => import("../views/About.vue"), //懒加载
    },

    {
      path: "/play",
      name: "Play",
      component: () => import("../views/Play.vue"), //懒加载
    },
    {
      path: "/love",
      name: "Love",
      component: () => import("../views/Love.vue"), //懒加载
    },
    {
      path: "/autotest",
      name: "AutoTest",
      component: () => import("../views/AutoTest.vue"), //懒加载
    },
    {
      path: "/:pathMatch(.*)*",
      name: "NotFound",
      component: () => import("../views/NotFound.vue"), //懒加载
    },
  ],
});
// 定义一个路由守卫，在每次路由变化后执行特定的操作
router.afterEach((to, from) => {
  // 触发一个自定义事件，通知其他代码路由已经发生变化
  window.dispatchEvent(new Event("routeChange"));
});
export default router;
